import axios from "../index.js";



// 菜单配置机构树
export const menuTree = (data) => {
  return axios.request({
    url: "/system/menu/tree",
    method: "get",
    data: data
  });
};

// 菜单新增
export const menuAdd = (data) => {
  return axios.request({
    url: "/system/menu/save",
    method: "post",
    data: data
  });
};

// 菜单详情
export const getById = (data) => {
  return axios.request({
    url: `/system/menu/getById?id=${data}`,
    method: "get"
  });
};


// 菜单修改
export const updById = (data) => {
  return axios.request({
    url: "/system/menu/updById",
    method: "post",
    data: data
  });
};

// 菜单与角色关联
export const batchSave = (data) => {
  return axios.request({
    url: "/system/roleMenu/batchSave",
    method: "post",
    data: data
  });
};

// 查询当前角色下有哪些菜单
export const getMenusByRoleId = (data) => {
  return axios.request({
    url: `/system/menu/getMenusByRoleId?roleId=${data}`,
    method: "get"
  });
};

// 查询当前角色下的树形结构菜单
export const getMenuTreeByRole = (data) => {
  return axios.request({
    url: `/system/menu/getMenuTreeByRole?roleId=${data}`,
    method: "get"
  });
};

// 查询当前菜单下的下属菜单
export const subMenulistPage = (data) => {
  return axios.request({
    url: "/system/menu/listPage",
    method: "post",
    data: data
  });
};

// 查询当前菜单绑定了那些角色
export const getRoleByMenuId = (data) => {
  return axios.request({
    url: `/system/menu/getRoleByMenuId?menuId=${data}`,
    method: "get"
  });
};


// 菜单关联按钮权限
export const updateComponentByIds = (data) => {
  return axios.request({
    url: "/system/menu/updateComponentByIds",
    method: "post",
    data: data
  });
};

// 查询当前菜单绑定了那些按钮
export const getBtnByMenuId = (data) => {
  return axios.request({
    url: `/system/menu/getBtnByMenuId?id=${data}`,
    method: "get"
  });
};


// 角色菜单关联按钮权限
export const saveMenuRoleComponent = (data) => {
  return axios.request({
    url: "/system/menuRoleComponent/save",
    method: "post",
    data: data
  });
};

// 查询当前角色菜单绑定了那些按钮
export const getBtns = (data) => {
  return axios.request({
    url: "/system/menuRoleComponent/getBtns",
    method: "post",
    data: data
  });
};
